package com.spring.controller;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Controller
public class Hello {

//    @Autowired
//    private DruidDataSource druidDataSource;1231313213133


    @GetMapping("hello")
    public String show(Model model,String id,String name){
        System.out.println("id"+id+"---name"+name);
//        HashMap<String, Object> hashMap = new HashMap<>();
//        hashMap.put("url",druidDataSource.getUrl());
       // hashMap.put("password",druidDataSource.getUrl());
        model.addAttribute("msg","这是我的第一个");
        model.addAttribute("birth",new Date());
        model.addAttribute("sex",0);
        ArrayList<String> list = new ArrayList<>();
       list.add("小白");
       list.add("小黑");
       list.add("小紫");
        model.addAttribute("list",list);
        return "hello";
    }

    @GetMapping("heihei/{id}/{name}")
    public String heihei(Model model, @PathVariable String id,@PathVariable String name){
        System.out.println("id"+id+"---name"+name);
//        HashMap<String, Object> hashMap = new HashMap<>();
//        hashMap.put("url",druidDataSource.getUrl());
        // hashMap.put("password",druidDataSource.getUrl());
        model.addAttribute("msg","这是我的第一个");
        model.addAttribute("birth",new Date());
        model.addAttribute("sex",0);
        ArrayList<String> list = new ArrayList<>();
        list.add("小白");
        list.add("小黑");
        list.add("小紫");
        model.addAttribute("list",list);
        return "hello";
    }
}
